package cn.tanghom.app.oa.service;

import java.util.Date;

import lombok.val;

import org.flowable.engine.delegate.BpmnError;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.tanghom.app.oa.repository.TalentRepository;

/**
 * 使用机器匹配算法，软匹配 
 * @author Hunteron-cp
 *
 */
@Service
public class MachineMatchDelegate implements JavaDelegate {
	
  @Autowired
  private TalentRepository talentRepository;

  @Override
  public void execute(DelegateExecution execution) {
    Date now = new Date();
    Object talentId = execution.getVariable("talentId");
    if(talentId==null){
    	execution.setTransientVariable("errorMessage", "not existed!");
    	throw new BpmnError("BusinessExceptionOccurred");
    	//return ;
    }   
    
    execution.setVariable("matchScore",0.5);
    
    Object talentDto = execution.getVariable("talent");
    
    System.out.println("Faux call to backend for ["  + execution.getVariable("positionId") + "]"+talentId);
  }

}
 